﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.BLL;
using Grove.ORM;
using HZ.MBSM.Model;
using HZ.MBSM.DBUtility;

public partial class Agency_xiugai : System.Web.UI.Page
{
    public int AccountId;
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCompany);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
            AccountId = SysFun.ToInt(_Account.AccountId);
            HZ.MBSM.DBUtility.Db db = new HZ.MBSM.DBUtility.Db(false);
            Grove.ORM.ObjectOperator oo = db.GetObjectOperator();

            HZ.MBSM.Model.Company Company = (HZ.MBSM.Model.Company)oo.Retrieve(typeof(HZ.MBSM.Model.Company), AccountId);
            HZ.MBSM.Model.Area Area = (HZ.MBSM.Model.Area)oo.Retrieve(typeof(HZ.MBSM.Model.Area), Company.AreaId);
            if (!IsPostBack)
            {
                this.TextBox0.Text = SysFun.ToTrim(Company.CompanyName);
                this.TextBox1.Text = SysFun.ToTrim(Company.UserCode);
                this.TextBox2.Text = SysFun.ToTrim(Company.memo5);
                this.TextBox3.Text = SysFun.ToTrim(Company.Telepone);
                this.TextBox4.Text = SysFun.ToTrim(Company.Email);
                this.TextBox5.Text = SysFun.ToTrim(Company.memo10);
                txtKmlxr.Text = SysFun.ToTrim(Company.Kmlxr);
                txtKmlxdh.Text = SysFun.ToTrim(Company.Kmlxdh);
            }

        }

    }

    protected void save_Click(object sender, EventArgs e)
    {
        Db ddd = new Db();
        string strsql = "update company set memo5='" + this.TextBox2.Text.Trim() + "',Telepone='" + this.TextBox3.Text.Trim() + "' , Email='" + this.TextBox4.Text.Trim() + "' , memo10='" + this.TextBox5.Text.Trim() + "',kmlxr='" + txtKmlxr.Text.Trim() + "',kmlxdh='" + txtKmlxdh.Text.Trim() + "' where AccountId=" + AccountId;
        int a = ddd.Command(strsql);
        ddd.Close();
        if (a < 1)
        {
            Response.Write("<script>alert('修改失败')</script>");
        }

        else
        {

            Response.Write("<script>alert('修改成功')</script>");
        }


    }
}
